package com.qiaoba.api.job.entity.dto;

import com.qiaoba.common.base.validate.AddGroup;
import com.qiaoba.common.base.validate.EditGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 定时任务DTO
 *
 * @author ailanyin
 * @date 2023-09-03 21:22:04
 */
@Data
public class SysJobDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "任务ID")
    @NotNull(message = "任务ID不能为空", groups = {EditGroup.class})
    @Size(max = 20, message = "任务ID不能超过{max}个字符", groups = {EditGroup.class})
    private String jobId;

    @Schema(description = "任务名称")
    @NotNull(message = "任务名称不能为空", groups = {AddGroup.class, EditGroup.class})
    @Size(max = 64, message = "任务名称不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String jobName;

    @Schema(description = "任务组名")
    @NotNull(message = "任务组名不能为空", groups = {AddGroup.class, EditGroup.class})
    @Size(max = 64, message = "任务组名不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String jobGroup;

    @Schema(description = "调用目标字符串")
    @NotNull(message = "调用目标字符串不能为空", groups = {AddGroup.class, EditGroup.class})
    @Size(max = 500, message = "调用目标字符串不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String invokeTarget;

    @Schema(description = "cron执行表达式")
    @Size(max = 500, message = "调用目标字符串不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String cronExpression;

    @Schema(description = "cron计划策略(默认执行_0 , 立即触发执行_1 , 触发一次执行_2 , 不触发立即执行_3)")
    @Size(max = 1, message = "cron计划策略不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String misfirePolicy;

    @Schema(description = "是否并发执行（1允许 0禁止）")
    @Size(max = 1, message = "并发执行不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String concurrent;

    @Schema(description = "任务状态（1正常 0暂停）")
    @Size(max = 1, message = "任务状态不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String status;

    @Schema(description = "备注")
    @Size(max = 500, message = "备注不能超过{max}个字符", groups = {AddGroup.class, EditGroup.class})
    private String remark;
}
